package de.baumann.browser.activitys.duobao

import android.content.Context
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.view.ViewPager
import de.baumann.browser.R
import de.baumann.browser.adapter.PagerAdapter
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.fragments.duobao.OrderJieXiaoFragment
import de.baumann.browser.fragments.duobao.OrderJinXingFragment
import de.baumann.browser.iview.IBaseView
import kotlinx.android.synthetic.main.activity_order_record.*
import kotlinx.android.synthetic.main.include_tool_bar_2.*

class OrderRecordActivity : BaseOdinActivity<IBaseView, BasePresenter<IBaseView>>() {

    companion object {
        fun startOrderRecordActivity(context: Context) {
            context.startActivity(Intent(context, OrderRecordActivity::class.java))
        }
    }

    override fun getTitleText(): String {
        return "订单记录"
    }

    override fun getLayout(): Int {
        return R.layout.activity_order_record
    }

    override fun getBackIcon(): Int {
        return R.drawable.ic_back
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)

        val fragments = arrayListOf(OrderJinXingFragment.instance,
                OrderJieXiaoFragment.instance)
        duobaoOrderViewPager.adapter = PagerAdapter(supportFragmentManager, fragments, null)
        duobaoOrderViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {

            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                when (position) {
                    0 -> jinxing.isChecked = true
                    1 -> jiexiao.isChecked = true
                }
            }

        })


        rgStatus.setOnCheckedChangeListener { _, i ->
            when (i) {
                R.id.jinxing -> {
                    duobaoOrderViewPager.currentItem = 0
                }

                R.id.jiexiao -> {
                    duobaoOrderViewPager.currentItem = 1
                }
            }
        }

    }

    override fun initData() {
    }

    override fun createPresenter(): BasePresenter<IBaseView>? {
        return null
    }

    override fun createView(): IBaseView? {
        return null
    }
}